package com.ruoyi.web.controller.caochong;


import com.ruoyi.web.domain.ScenicSpot;
import com.ruoyi.web.dto.CommentDto;
import com.ruoyi.web.service.caochongService.ScenicSpotService;
import com.ruoyi.web.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 曹冲
 * @since 2022-11-05
 */
@Slf4j
@RestController
@RequestMapping("/web/scenic-spot")
public class ScenicSpotController {

    @Autowired
    private ScenicSpotService scenicSpotService;


    /**
     * 根据商家id查询出对应的商家信息以及相应的评论
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public R getById(@PathVariable Integer id){
        return R.ok(scenicSpotService.findScenicById(id));
    }

    /**
     *
     * @return
     */
    @GetMapping()
    public R getAll(){
        ArrayList<ScenicSpot> list = new ArrayList<>();
        List<ScenicSpot> scenicSpots = scenicSpotService.lambdaQuery().list();
        list.addAll(scenicSpots);
        return R.ok(list);
    }

}

